package com.lw.system.controller;

import java.util.List;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.lw.common.basemodel.Json;
import com.lw.common.core.service.BaseServiceI;
import com.lw.common.web.controller.BaseController;
import com.lw.system.model.Resource;
import com.lw.system.service.ResourceServiceI;
/**
 * 
* @Title: ResourceController.java 
* @Package com.lw.controller 
* @Description: 资源业务
* @author 刘伟  15818570028@163.com   
* @date 2016年12月21日 下午6:57:41 
* @version V1.0
 */
@RestController
@RequestMapping("/resource")
public class ResourceController extends
		BaseController<Resource, String> {
	
	@javax.annotation.Resource
	private ResourceServiceI resourceService;
	@Override
	public BaseServiceI<Resource, String> getBaseService() {
		return resourceService;
	}
	

	@RequestMapping(value = "/findAllTreeNode", method = RequestMethod.GET)
	public List<Resource> findAllTreeNode() {
		return resourceService.findAllTreeNode();
	}

	@RequestMapping(value = "/treegrid", method = RequestMethod.GET)
	public List<Resource> treegrid() {
		return resourceService.treegrid();
	}

	@RequestMapping(value = "/remove", method = RequestMethod.POST)
	public Json remove(String id) {
		return resourceService.remove(id) > 0 ? setSimpleSuccess(id)
				: setFailed();
	}

	@RequestMapping(value = "/add", method = RequestMethod.POST)
	public Json add(Resource r) {

		return resourceService.add(r) > 0 ? setSimpleSuccess(r)
				: setFailed();
	}

	@RequestMapping(value = "/edit", method = RequestMethod.POST)
	public Json edit(Resource r) {

		return resourceService.edit(r) > 0 ? setSimpleSuccess(r)
				: setFailed();
	}

	

	

}
